package user

import java.util.Date;
import security.Role;
import org.apache.shiro.crypto.hash.Sha256Hash;
import user.Professor;
/**
 * ProfessorCreationService
 * A service class encapsulates the core business logic of a Grails application
 */
class ProfessorService {
	def securityService
    static transactional = true

    def create(params) {
		
		params.username = params.professorId.toString()
		params.passwordHash = new Sha256Hash(params.professorId.toString()).toHex()
		
		def professor = new Professor(params)
		def role = Role.findByName(securityService.PROFESSOR_ROLE)
		professor.addToRoles(role)
		return professor
		
    }
}
